' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.08.29.21.34]) on 2023.09.28 at 02:22 (Coordinated Universal Time)
' BAM port and mod by Charlie Veniot
' of the QBJS "Fractal Fern" program found at https://github.com/boxgaming/qbjs/wiki/Samples

Screen _newimage(255, 500, 27) ' switched to screen mode 27 from screen mode 12 and set to portrait dimensions
Randomize Timer
Dim As Single X, Y, xx, yy
Dim as LONG i
Dim as INTEGER n
NewFern:
  Color _RGB(Rnd * 256, Rnd * 256, Rnd * 256)
  X = 0 : Y = 0 
  For i = 1 TO 100000
      n = RND * 100
      If n < 1 Then
          Xp = 0
          Yp = .16 * Y
      ElseIf n >= 1 And n <= 8 Then
          Xp = .2 * X - .26 * Y
          Yp = .23 * X + .22 * Y + 1.6
      ElseIf n >= 8 And n <= 15 Then
          Xp = -.15 * X + .28 * Y
          Yp = .26 * X + .24 * Y + .44
      Else
          Xp = .85 * X + .04 * Y
          Yp = -.04 * X + .85 * Y + 1.6
      End If
      X = Xp
      Y = Yp
      xx = int(X * 45)
      yy = int(Y * 45 - 225)
      PSet (xx + 120, -yy + 240)
      IF i mod 500 = 0 THEN _delay 0.01
  Next i
_DELAY 1
GOTO NewFern